#containers
tree.ui = {}

funcs = []

tree.ui.add_onload = (func) ->
    funcs.push func

###
window.onload = () ->
    for func in funcs
        func()
###
###
set up drag and drop
###
drag_over = (event) -> 
    event.preventDefault()
    return false

tree.ui.add_onload(() ->
    drop = (event) ->
        data = tree.io.formats.json.load(event.dataTransfer.getData('text/plain'))
        htmlelem = document.getElementById data.id
        htmlelem.style.left = (event.clientX + data.x) + 'px'
        htmlelem.style.top = (event.clientY + data.y) + 'px'
        event.preventDefault()
        return false
    
    document.body.addEventListener 'dragover',drag_over,false
    document.body.addEventListener 'drop', drop, false
)
